package com.naico.util;

import com.naico.core.pojo.DebtInformation;

import java.util.List;

/**
 * User: Dawood Ajaz
 * Date: Dec 28, 2008
 * Time: 7:36:09 PM
 */
public class FinancialUtility {

    public static long round(double value) {
        return Math.round(value);
    }

    public static double computeEndingBalance(double balance, double payment, double interest) {
        // calculate ending balance
        return (balance - (payment - interest));
    }

    public static double computeMonthlyInterest(double balance, double interestRate) {
        // compute monthly interest
        return (balance * interestRate / 1200);
    }

    public static double getTotalMinimumPayment(List<DebtInformation> debtInformations) {
        double totalMinimumPayment = 0.0;
        for (DebtInformation debtInfo : debtInformations) {
            totalMinimumPayment += debtInfo.getMinimumPayment();
        }
        return totalMinimumPayment;
    }

    public static double getTotalActualPayment(List<DebtInformation> debtInformations) {
        double totalActualPayment = 0.0;
        for (DebtInformation debtInfo : debtInformations) {
            totalActualPayment += debtInfo.getActualPayment();
        }
        return totalActualPayment;
    }


}
